package com.cunyu;

import javax.servlet.ServletException;

import org.springframework.web.servlet.DispatcherServlet;

import cn.tom.mvc.UndertowStart;
import com.cunyu.listener.Listener;
import io.undertow.servlet.Servlets;
import io.undertow.servlet.api.ServletInfo;
import io.undertow.servlet.handlers.DefaultServlet;

public class MainRun {

	public static void main(String[] args) throws ServletException {
		//-rpath ../src/main/webapp
		ServletInfo dispatcherServlet =  Servlets.servlet(DispatcherServlet.class)
				.addInitParam("contextConfigLocation", "/WEB-INF/cfg/application-mvc.xml")
				.addInitParam("throwExceptionIfNoHandlerFound","true")
				.addMapping("/").setLoadOnStartup(1);

		ServletInfo defaultServlet = Servlets.servlet(DefaultServlet.class)
				.addMappings("*.js","*.map","*.css","*.jpg","*.gif","*.png","*.ico","*.inc",
						"*.xls","*.xml","*.ttf","*.woff","*.woff2","*.svg","*.txt")
				.setLoadOnStartup(1);
		new UndertowStart(MainRun.class).init(args)
		.addInitParam("logbackConfigLocation", "/WEB-INF/cfg/logback.xml")
		.addInitParam("contextConfigLocation", "/WEB-INF/cfg/applicationContext.xml")
		.addServlet(dispatcherServlet)
		.addServlet(defaultServlet) // 没有加载到
//		.addFilter(webStatFilter)
		.addlistener(Listener.class)
		.start();
		
	}
}
